home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / xachvision < prev    next >
Encoding:
Text File  |  2001-06-26  |  1.5 KB  |  56 lines

  1. #!/usr/app/bin/perl
  2.  
  3. # Once again, an effect of Xach's
  4. # Created by Seth Burgess <sjburges@gimp.org>
  5.  
  6. use Gimp qw(:auto __ N_);
  7. use Gimp::Fu;
  8.  
  9. register "xachvision",
  10.          "Xach Surveillance Camera/XachVision",
  11.          "This makes an interlaced-looking machine vision type thing.",
  12.          "Seth Burgess",
  13.          "Seth Burgess <sjburges\@gimp.org>",
  14.          "2000-11-25",
  15.          N_"<Image>/Filters/Noise/Xach Vision...",
  16.          "RGB*, GRAY*",
  17.          [
  18.           [PF_COLOR,    "color",    "What Color to see the world in", [0, 255, 0]],
  19.       [PF_SLIDER,   "added_noise", "How much noise to add", 25, [0,255,5]]
  20.          ],
  21.          sub {
  22.    my($img,$drawable,$color,$amt) =@_;
  23.  
  24.   eval { $img->undo_push_group_start };
  25.     $oldbackground = gimp_palette_get_background();
  26.  
  27.     $midlayer = $drawable->gimp_layer_copy(1);
  28.     $img->add_layer($midlayer, 0);
  29.  
  30.     $toplayer = $drawable->gimp_layer_copy(1);
  31.     $img->add_layer($toplayer, 0);
  32.  
  33.     gimp_palette_set_background($color);
  34.     $toplayer->edit_fill(BG_IMAGE_FILL);
  35.     $toplayer->set_mode(COLOR_MODE);
  36.     
  37.     gimp_palette_set_background([0,0,0]);
  38.     $drawable->edit_fill(BG_IMAGE_FILL);
  39.  
  40.     $amt = $amt/255;
  41.     $midlayer->plug_in_noisify(1,$amt, $amt, $amt, $amt);
  42.     $midmask = $midlayer->create_mask(0);
  43.     $img->add_layer_mask($midlayer,    $midmask);
  44.     $midmask->plug_in_grid(1,$img->height * 3,0,[0,0,0],255, 1,3,0,[0,0,0],255,
  45.                            0,0,0,[0,0,0],255 );
  46.     $midmask->plug_in_gauss_iir(1.01, 1, 1);
  47.  
  48.     gimp_palette_set_background($oldbackground);
  49.   eval { $img->undo_push_group_end };
  50.     gimp_displays_flush();
  51.     return();
  52. };
  53.  
  54. exit main;
  55.  
  56.